import { handleActions, } from 'redux-actions';
import * as types from '../constants/actionTypes';

const initialState = {
  loading: true,
  logged: false,
};

const handler = {};

handler[types.BASE_LOADING] = (state, action) => {
  const { loading, } = action;
  return {
    ...state,
    loading,
  };
};

handler[types.SET_SIGIN_STATE] = (state, action) => {
  const { logged, } = action;
  return {
    ...state,
    logged,
  };
};

handler[types.SET_AUTH_STATE] = (state, action) => {
  const { authed, } = action;
  return {
    ...state,
    authed,
  };
};

handler[types.SET_OPEN_ACCOUNT_STATE] = (state, action) => {
  const { hasOpenAccount, } = action;
  return {
    ...state,
    hasOpenAccount,
  };
};

handler[types.SET_CITY_STATE] = (state, action) => {
  const { cityList, } = action;
  return {
    ...state,
    cityList,
  };
};

handler[types.SET_COUNTRY_STATE] = (state, action) => {
  const { counyrtList, } = action;
  return {
    ...state,
    counyrtList,
  };
};

handler[types.SET_CHOOSE_TYPE] = (state, action) => {
  const { type, } = action;
  return {
    ...state,
    type,
  };
};

handler[types.SET_DEAL_OUT_TYPE] = (state, action) => {
  const { dealTime, } = action;
  return {
    ...state,
    dealTime,
  };
};

handler[types.GET_SUBMIT_STATE] = (state, action) => {
  const { imgUploadTime, } = action;
  return {
    ...state,
    imgUploadTime,
  };
};

export default handleActions(handler, initialState);
